package com.xxwy.dependency;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.BeanNameAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;

/**
 * @author wy
 * @date 2020/4/20 9:50
 */
@Getter
@Setter
public class User implements BeanNameAware {
  private Integer id;
  private String name;
  private City city;

  private City[] workCities;
  private List<City> liveCities;

  public User() {
    System.out.println("user 实例化");
  }

  public User(Integer id) {
    this.id = id;
  }

  private String beanName;

  @PostConstruct
  public void init(){
    System.out.println(beanName+ " -User PostConstruct");
  }

  @PreDestroy
  public void destroy(){
    System.out.println(beanName+" -User PreDestroy");
  }

  @Override
  public void setBeanName(String name) {
    beanName = name;
  }
}
